<?php
$newpw = $_POST['newun'];

$confirmpw = $_POST['confirmun'];

if($newpw==$confirmpw && $newpw!='' && $confirmpw!=''){

    session_start();

    include '../../config/database.php';
    $con = mysqli_connect($dbhost,$dbuser,$dbpasswd,$dbname);

    $sqlname = $dbprefix.'users';
        $sql = "UPDATE `".$sqlname."` SET `username` = '".$newpw."' WHERE `username` LIKE '".$_SESSION['username']."'";
        $a = mysqli_query( $con, $sql );
        echo json_encode(  array(  'code' => 0 ,'data' => array('msg' => "用户名修改成功，请重新登陆" , 'raw' => $sql)  )  );
        exit(1);
}
else{
    if($newpw=='' || $confirmpw=='')
    {echo json_encode(  array(  'code' => 1 ,'data' => array('msg' => "新用户名不能为空，请重新输入" )  )  ); exit(1);}
    if($newpw!=$confirmpw)
    {    echo json_encode(  array(  'code' => 1 ,'data' => array('msg' => "两次用户名不相等，请重新输入" )  )  ); exit(1);}
}
?>